package com.venus.common.utils;

import java.awt.Color;
import java.util.Random;

public class ColorUtil {

	
	/**
	 * 得到随机颜色
	 * @return
	 */
	public static Color getRandomColor(){
		Random objRandom = new Random();
		int r = objRandom.nextInt(255);
		int g = objRandom.nextInt(255);
		int b = objRandom.nextInt(255);
		Color color = new Color(r,g,b);
		return color;
	}
	
	/**
	 * 得到随机颜色的编码  如:#9017dd
	 * @return
	 */
	public static String getRandomColorCode(){
		Color color = getRandomColor();
		StringBuffer sb = new StringBuffer(8);
		sb.append("#");
		sb.append(Integer.toHexString(color.getRed()));
		sb.append(Integer.toHexString(color.getGreen()));
		sb.append(Integer.toHexString(color.getBlue()));
		return sb.toString();
	}
	
	
	public static void main(String[] args) {
		System.out.println(getRandomColorCode());
	}
}
